home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbnws102.zip / GRAPHSPK.ZIP / GETSIZE.BAS < prev    next >
BASIC Source File  |  1989-12-28  |  4KB  |  88 lines

  1. '=========================== GETSIZE.BAS ==================================
  2. '                          Quick Basic 4.5
  3. '                 Copyright 1989 - Frederick Volking
  4. ' All Rights released to public domain by original author on 12/01/89
  5. '
  6. ' =====================================================================
  7. '
  8. ' This SUB calculates the Array size needed for a graphics GET
  9. ' image function. Works with SCREEN modes 1,2,7,8,9,10,11,12,13
  10. '
  11. '        WARNING: Only tested on SCREEN modes 1,2,7,8,9...
  12. '
  13. ' Provides two seperate functions as based on incomming value of
  14. ' "DoingText" variable:
  15. '
  16. '  1) If "DoingText" is TRUE (non-zero): then routine assumes
  17. '     values passed in LRow,LCol,RRow,RCol as text oriented
  18. '     row and column coordinates. Thus it converts the text
  19. '     coordinates to appropriate pixel coordinates and
  20. '     calculates pixel area necessary to GET an image to fill
  21. '     the described rows and columns area. IMPORTANT! before
  22. '     return, LRow,LCol,RRow,RCol are CONVERTED from text
  23. '     oriented coordinates to pixel oriented coordinates
  24. '     describing the exact boundries needed to be used by the
  25. '     GET statement.
  26. '
  27. '  2) If DoingText is FALSE (0): then the routine assumes the
  28. '     values passed in LRow,LCol,RRow,RCol as describing a
  29. '     pixel oriented area.
  30. '
  31. ' ----------- Notes on Improvements Suggested -----------------
  32. '
  33. ' Note #0: Commercial routines exist to perform all below
  34. '   suggested improvements. But for copyright reasons, I'm
  35. '   not at liberty to include them herein ....
  36. '
  37. ' Note #1: ScreenMode - Rather than being passed to the routine,
  38. '   it would be more functional if routine made own determination.
  39. '
  40. ' Note #2: Planes in EGA#9 could be set to Planes = 2 if a
  41. '   method could be devised to determine if the currently
  42. '   installed EGA card HAS MORE OR LESS THAN 64K of onboard memory
  43. '       ie;  IF > 64k THEN Planes = 4 ELSE Planes = 2
  44. '
  45. ' Note #3 - LINES - Only needed in EGA and VGA modes(25,30,43,60)
  46. '   Rather than being passed, would be more functional if routine
  47. '   made determination itself and took appropriate action
  48. '
  49. ' ==================================================================
  50. '  Author:       Frederick Volking
  51. '  Contact:      (415)952-3450 [home]          (415)378-4640 [work]
  52. '  USPO Mail:    425 Larch Avenue  -  South San Francisco, CA 94080
  53. '  EchoMail:     ANY Basic conference (I try to read them all)
  54. '  Library At:   QBCentral BBS - Vancouver Washington (206)892-7500
  55. ' ==================================================================
  56. DEFINT A-Z
  57. SUB GetSize(IntNeed,LRow,LCol,RRow,RCol,DoingText,ScreenMode,Lines)STATIC
  58.  
  59.    SELECT CASE ScreenMode                    ' See Note #1
  60.       CASE  1: Bits = 2: Planes = 1 'CGA
  61.       CASE  2: Bits = 1: Planes = 1 'CGA
  62.       CASE  7: Bits = 1: Planes = 4 'EGA
  63.       CASE  8: Bits = 1: Planes = 4 'EGA
  64.       CASE  9: Bits = 1: Planes = 4 'EGA     ' See Note #2
  65.       CASE 10: Bits = 1: Planes = 2 'VGA
  66.       CASE 11: Bits = 1: Planes = 1 'VGA
  67.       CASE 12: Bits = 1: Planes = 4 'VGA
  68.       CASE 13: Bits = 8: Planes = 1 'VGA
  69.    END SELECT
  70.  
  71.    IF DoingText THEN
  72.       SELECT CASE ScreenMode                 ' See Note #3
  73.          CASE  9,10
  74.             IF Lines=43 THEN CharPixTall= 8 ELSE CharPixTall=14
  75.          CASE 11,12
  76.             IF Lines=30 THEN CharPixTall=16 ELSE CharPixTall= 8
  77.          CASE ELSE: CharPixTall=8
  78.       END SELECT
  79.       LRow = (LRow - 1) * CharPixTall
  80.       LCol = (LCol - 1) * 8
  81.       RRow = (RRow * CharPixTall) - 1
  82.       RCol = (RCol * 8) - 1
  83.    END IF
  84.  
  85.    IntNeed = 4+INT(((RCol-LCol+1)*(Bits)+7)/8)*Planes*((RRow-LRow)+1)
  86.    IntNeed = INT(CSNG(IntNeed+1)/2)
  87.  
  88. END SUB